/**
 * 项目示例-列表表头
 * Date 2023-5-25 09:33:56
 * 可选参数可参考：https://element-plus.org/zh-CN/component/table.html#table-column-属性
 */
interface ExampleListItem {
  houseName: string;
  houseType: string;
  houseCode: string;
  num: string;
  area: string;
  price: string;
  rent: string;
  region: string;
  organNames: string;
  condition: string;
  nature: string;
  ability: string;
  maintainLimit: string;
  dutyOrganName: string;
  linkUserName: string;
  linkPhone: string;
  floor: string;
  coordinate: string;
  lastUpdateTime: string;
}

export const mapListColumns = [
  { type: 'index', label: '序号', width: 60, align: 'center' },
  {
    prop: 'houseName', label: '名称', width: 130, align: 'center', ellipsis: true
  },
  {
    prop: 'houseType',
    label: '类型',
    minWidth: 130,
    align: 'center',
    ellipsis: true,
    formatter: function (row: any, column: any, cellValue: any) {
      if (cellValue) {
        return cellValue
      } else {
        return '-'
      }
    }
  },
  {
    prop: 'houseCode',
    label: '编号',
    sortable: true,
    width: 130,
    align: 'center',
    ellipsis: true,
    formatter: function (row: any, column: any, cellValue: any) {
      if (cellValue) {
        return cellValue
      } else {
        return '-'
      }
    }
  },

  {
    prop: 'num',
    label: '数量',
    sortable: true,
    minWidth: 200,
    align: 'center',
    ellipsis: true,
    formatter: function (row: any, column: any, cellValue: any) {
      if (cellValue) {
        return cellValue
      } else {
        return '-'
      }
    }
  },
  {
    prop: 'area',
    label: '面积(m²)',
    sortable: true,
    minWidth: 150,
    align: 'center',
    ellipsis: true,
    formatter: function (row: any, column: any, cellValue: any) {
      if (cellValue) {
        return cellValue
      } else {
        return '-'
      }
    }
  },
  {
    prop: 'price',
    label: '单价(万)',
    sortable: true,
    minWidth: 120,
    align: 'center',
    ellipsis: true,
    formatter: function (row: any, column: any, cellValue: any) {
      if (cellValue) {
        return cellValue
      } else {
        return '-'
      }
    }
  },
  {
    prop: 'rent',
    label: '月租金',
    sortable: true,
    minWidth: 120,
    align: 'center',
    ellipsis: true,
    formatter: function (row: any, column: any, cellValue: any) {
      if (cellValue) {
        return cellValue
      } else {
        return '-'
      }
    }
  },
  {
    prop: 'region',
    label: '区域',
    width: 210,
    align: 'center',
    ellipsis: true,
    formatter: function (row: any, column: any, cellValue: any) {
      if (cellValue) {
        return cellValue
      } else {
        return '-'
      }
    }
  },
  {
    prop: 'organNames',
    label: '使用单位',
    minWidth: 120,
    align: 'center',
    ellipsis: true,
    formatter: function (row: any, column: any, cellValue: any) {
      if (cellValue) {
        return cellValue
      } else {
        return '-'
      }
    }
  },
  {
    prop: 'state',
    label: '状态',
    sortable: true,
    minWidth: 120,
    align: 'center',
    ellipsis: true,
    formatter: function (row: any, column: any, cellValue: any) {
      if (row.state === '1') {
        return '使用中'
      } else if (row.state === '2') {
        return '已废弃'
      }
    }
  },
  {
    prop: 'nature',
    label: '性质',
    width: 210,
    align: 'center',
    ellipsis: true,
    formatter: function (row: any, column: any, cellValue: any) {
      if (cellValue) {
        return cellValue
      } else {
        return '-'
      }
    }
  },
  {
    prop: 'ability',
    label: '功能',
    width: 210,
    align: 'center',
    ellipsis: true,
    formatter: function (row: any, column: any, cellValue: any) {
      if (cellValue) {
        return cellValue
      } else {
        return '-'
      }
    }
  },
  {
    prop: 'maintainLimit',
    label: '维保年限',
    width: 210,
    align: 'center',
    ellipsis: true,
    formatter: function (row: any, column: any, cellValue: any) {
      if (cellValue) {
        return cellValue
      } else {
        return '-'
      }
    }
  },
  {
    prop: 'dutyOrganName',
    label: '责任单位',
    width: 210,
    align: 'center',
    ellipsis: true,
    formatter: function (row: any, column: any, cellValue: any) {
      if (cellValue) {
        return cellValue
      } else {
        return '-'
      }
    }
  },
  {
    prop: 'linkUserName',
    label: '联系人',
    width: 210,
    align: 'center',
    ellipsis: true,
    formatter: function (row: any, column: any, cellValue: any) {
      if (cellValue) {
        return cellValue
      } else {
        return '-'
      }
    }
  },
  {
    prop: 'linkPhone',
    label: '联系人电话 ',
    width: 210,
    align: 'center',
    ellipsis: true,
    formatter: function (row: any, column: any, cellValue: any) {
      if (cellValue) {
        return cellValue
      } else {
        return '-'
      }
    }
  },
  {
    prop: 'floor',
    label: '楼层   ',
    width: 210,
    align: 'center',
    ellipsis: true,
    formatter: function (row: any, column: any, cellValue: any) {
      if (cellValue) {
        return cellValue
      } else {
        return '-'
      }
    }
  },
  {
    prop: 'coordinate',
    label: '地图坐标',
    width: 210,
    align: 'center',
    formatter(row: any, column: any, cellValue: any) {
      const r = ''
      if (cellValue instanceof Array) {
        row.coordinate.forEach((e: any) => {
          if (e?.latitude && e?.longitude) {
            // @ts-ignore
            r += '(' + e.latitude + ',' + '  ' + e?.longitude + ')'
          } else {
            return '-'
          }
        })
      } else {
        return '-'
      }
      return r
    },
    ellipsis: true
  },
  {
    prop: 'lastUpdateTime',
    label: '更新时间',
    sortable: true,
    width: 210,
    align: 'center',
    ellipsis: true,
    formatter: function (row: any, column: any, cellValue: any) {
      if (cellValue) {
        return cellValue
      } else {
        return '-'
      }
    }
  },
  {
    prop: 'action', label: '操作', fixed: 'right', width: 210, align: 'center'
  }
]
